package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Optional;
@Mapper
public interface UserMapper {
    @Select("select * from user")
    List<User> findAll();

//    @Insert("insert into sys_user(username,password,email,phone,nickname,address) " +
//            "VALUES(#{username},#{password},#{email},#{phone},#{nickname},#{address});")
//    int insert(User user);

    @Select("select * from user where studentNumber == #{studentNumber}")
    User findStudentNumber(@Param("studentNumber") String studentNumber);

    @Select("select * from user where password == #{password}")
    User findPassword(@Param("password") String password);

    @Insert("insert into user(studentNumber,password)" + "VALUES(#{studentNumber},#{password}); ")
    User insert(@Param("studentNumber") String studentNumber,@Param("password") String password);

    @Update("update user set password = #{password} where studentNumber = #{studentNumber}")
    User update(@Param("studentNumber") String studentNumber,@Param("password") String password);

    @Select("select name from user where id=#{id}")
    String adminName(@Param("id") Integer id);
}
